import request from '@/utils/request'

/**
 * 操作日志管理API接口
 */

// 分页查询操作日志列表
export function getOperationLogPage(currentPage, pageSize, queryData) {
  return request({
    url: `/api/operation-logs/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryData
  })
}

// 条件查询操作日志
export function searchOperationLogs(queryData) {
  return request({
    url: '/api/operation-logs/search',
    method: 'post',
    data: queryData
  })
}

// 根据ID查询操作日志详情
export function getOperationLogById(logId) {
  return request({
    url: `/api/operation-logs/${logId}`,
    method: 'get'
  })
}

// 获取操作日志统计信息
export function getOperationLogStatistics(queryData) {
  return request({
    url: '/api/operation-logs/statistics',
    method: 'get',
    params: queryData
  })
}

// 获取操作类型统计图表数据
export function getOperationTypeStatistics(timeRange) {
  return request({
    url: '/api/operation-logs/statistics/operation-type',
    method: 'get',
    params: { timeRange }
  })
}

// 获取用户活跃度统计数据
export function getUserActivityStatistics(timeRange) {
  return request({
    url: '/api/operation-logs/statistics/user-activity',
    method: 'get',
    params: { timeRange }
  })
}

// 获取时间趋势分析数据
export function getTimeTrendStatistics(timeRange) {
  return request({
    url: '/api/operation-logs/statistics/time-trend',
    method: 'get',
    params: { timeRange }
  })
}

// 检测异常操作
export function detectAbnormalOperations(queryData) {
  return request({
    url: '/api/operation-logs/detect-abnormal',
    method: 'post',
    data: queryData
  })
}

// 导出操作日志
export function exportOperationLogs(queryData) {
  return request({
    url: '/api/operation-logs/export',
    method: 'post',
    data: queryData,
    responseType: 'blob'
  })
}

// 批量删除操作日志
export function batchDeleteOperationLogs(logIds) {
  return request({
    url: '/api/operation-logs/batch',
    method: 'delete',
    data: logIds
  })
}

// 删除单个操作日志
export function deleteOperationLog(logId) {
  return request({
    url: `/api/operation-logs/${logId}`,
    method: 'delete'
  })
}

// 清理过期日志
export function cleanExpiredLogs(days) {
  return request({
    url: '/api/operation-logs/clean',
    method: 'delete',
    params: { days }
  })
}

// 获取操作日志统计概览
export function getOperationLogOverview() {
  return request({
    url: '/api/operation-logs/overview',
    method: 'get'
  })
}